package com.ikas.ai.framework.core.listener;

import com.ikas.ai.framework.core.event.FlowEvent;
import lombok.extern.slf4j.Slf4j;

import java.util.Objects;

/**
 * @Description: 流程日志listener
 * @Author: qi.yilai
 * @Date: 2022/8/11 17:57
 * @Version: 1.0.0
 **/
@Slf4j
public class FlowLogListener implements FlowListener{

    @Override
    public boolean fireEvent(FlowEvent event) {
        log.info("Flow信息-flowName:{}, flowId:{}, flowInstance:{}, flowStatus:{}, event:{}, errors size:{}", event.getOwner().getName(),
                event.getOwner().getFlowId(),
                event.getOwner().getFlowInstanceId(),
                event.getOwner().getStatus().getCode(),
                Objects.isNull(event.getTarget()) ? "" : event.getTarget().toString(),
                event.getOwner().errorSize());
        return true;
    }
}
